<!DOCTYPE html>
<html>

<head>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'user.label', default: 'user')}"/>
    <title>新增企业固定资产</title>
</head>

<body class="fixed-navbar fixed-sidebar">
<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb">
                    <li>贷款管理系统</li>
                    <li class="active">
                        <span>新增企业固定资产</span>
                    </li>
                </ol>
            </div>

            <h2 class="font-light m-b-xs">
                新增企业固定资产
            </h2>
        </div>
    </div>
</div>

<div class="content animate-panel">
    <div class="row">
        <div class="hpanel hblue">
            <div class="panel-heading">
                新增企业固定资产
            </div>

            <div class="panel-body">
                <g:form action="save" class="form-horizontal">
                    <g:if test="${flash.message}">
                        <div class="message alert alert-info" role="status">${flash.message}</div>
                    </g:if>
                    <g:hasErrors bean="${this.propertyInformation}">
                        <ul class="errors" role="alert">
                            <g:eachError bean="${this.propertyInformation}" var="error">
                                <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>>
                                    <g:message error="${error}"/>
                                </li>
                            </g:eachError>
                        </ul>
                    </g:hasErrors>
                    <div class="form-group">
                        <label class="col-md-2 control-label">公司名称</label>

                        <div class="col-md-3">
                            <g:select class="form-control" name="account" value="${accountId}"
                                      optionKey="id" optionValue="name" from="${com.next.Account.list()}" disabled="true"/>
                        </div>
                        <label class="col-md-2 control-label">权利证书号</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="certificate.serialNumber" id="certificate" onchange="getCertificateNumber()"/>
                            <input class="form-control" name="certificate.id" type="hidden" id="certificateId"
                                   value="${propertyInformation?.certificate?.id}">
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">币种</label>

                        <div class="col-md-3">
                            <g:select class="form-control" name="currencyType" value="${this.propertyInformation?.currencyType?.name}"
                                      optionKey="id" optionValue="name" from="${com.next.CurrencyType.list()}"
                                      noSelection="['': '-请选择-']"/>
                        </div>
                        <label class="col-md-2 control-label">评估日期</label>

                        <div class="col-md-3 datePicker">
                            <g:datePicker name="valuationDate"  value="" precision="day"/>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">评估机构</label>

                        <div class="col-md-3">
                            <g:select class="form-control" name="valuationProvider" value="${this.propertyInformation?.valuationProvider?.name}"
                                      optionKey="id" optionValue="name" from="${com.next.PropertyValuationProvider.list()}"
                                      noSelection="['': '-请选择-']"/>
                        </div>
                        <label class="col-md-2 control-label">资产净值</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="totalPrice" id="totalPrice"/>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">固定资产名称</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="name" id="name"/>
                        </div>
                        <label class="col-md-2 control-label">资产状态</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="status" id="status"/>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">资产类型</label>

                        <div class="col-md-3">
                            <g:select class="form-control" name="type" value="${this.propertyInformation?.type?.name}"
                                      optionKey="id" optionValue="name" from="${com.next.PropertyType.list()}"
                                      noSelection="['': '-请选择-']"/>
                        </div>
                        <label class="col-md-2 control-label">入账价值</label>

                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="appliedTotalPrice" id="appliedTotalPrice"/>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">更新日期</label>

                        <div class="col-md-3 datePicker">
                            <g:datePicker name="modifiedDate"  value="" precision="day"/>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <g:hiddenField name="targetUri"  value="${targetUri}"/>
                    <g:hiddenField name="account.id"  value="${accountId}"/>
                    <div class="form-group">
                        <div class="col-md-1 col-md-offset-5">
                            <g:submitButton class="btn btn-info" name="create" value="保存"/>
                        </div>
                    </div>
                </g:form>
            </div>
        </div>
    </div>
</div>
<g:javascript>
    function getCertificateNumber() {
            $.ajax({
                type: "POST",
                url: "/propertyInformation/createCertificateNumber",
                data: {
                    serialNumber: $("#certificate").val(),
                    account: $("#account").val()
                },

                success: function (data) {

                    var id = data.certificate.id;
                    $("#certificateId").val(id);
                },
                error: function () {
                    swal("获取失败，请稍后重试", "", "error");
                }
            });
        }

</g:javascript>
</body>
</html>
